package com.hongtech.modules.knowledge.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hongtech.common.service.impl.CrudServiceImpl;
import com.hongtech.common.util.BeanCopierUtils;
import com.hongtech.modules.knowledge.mapper.BannerMapper;
import com.hongtech.modules.knowledge.dto.BannerDTO;
import com.hongtech.modules.knowledge.entity.BannerEntity;
import com.hongtech.modules.knowledge.service.BannerService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 横幅表
 *
 * @author lch 123456789@qq.com
 * @since 1.0.0 2023-09-13
 */
@Service
public class BannerServiceImpl extends CrudServiceImpl<BannerMapper, BannerEntity, BannerDTO> implements BannerService {

    @Override
    public List<BannerDTO> listHomeBanner() {
        LambdaQueryWrapper<BannerEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BannerEntity::getPosition, 1);
        queryWrapper.eq(BannerEntity::getEnabled, 1);
        List<BannerEntity> list = baseDao.selectList(queryWrapper);
        return BeanCopierUtils.copyPropertiesList(list, BannerDTO.class);
    }

}
